/// @tags: GeneralSuffixAutoMaton
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>

using namespace std;

namespace BlueQuantum {

typedef long long LL;

constexpr int MAXN = 2e6 + 5, CHARSET = 26;

int n, samcnt = 1;
int link[MAXN], len[MAXN], ch[MAXN][CHARSET];
char str[MAXN];

inline int insert(int c, int lst) {
  if (ch[lst][c]) {
    int p = lst, q = ch[p][c];
    if (len[p] + 1 == len[q])
      return q;
    else {
      int nq = ++samcnt;
      len[nq] = len[p] + 1;
      memcpy(ch[nq], ch[q], sizeof(ch[nq]));
      link[nq] = link[q], link[q] = nq;
      while (p && ch[p][c] == q) ch[p][c] = nq, p = link[p];
      return nq;
    }
  }
  int cur = ++samcnt, p = lst;
  len[cur] = len[lst] + 1;
  while (p && ch[p][c] == 0) ch[p][c] = cur, p = link[p];
  if (!p)
    link[cur] = 1;
  else {
    int q = ch[p][c];
    if (len[p] + 1 == len[q])
      link[cur] = q;
    else {
      int nq = ++samcnt;
      len[nq] = len[p] + 1;
      memcpy(ch[nq], ch[q], sizeof(ch[nq]));
      link[nq] = link[q], link[cur] = link[q] = nq;
      while (p && ch[p][c] == q) ch[p][c] = nq, p = link[p];
    }
  }
  return cur;
}

inline int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> (str + 1);
    int lst = 1;
    for (int j = 1; str[j]; ++j) lst = insert(str[j] - 'a', lst);
  }
  LL ans = 0;
  for (int i = 2; i <= samcnt; ++i) ans += len[i] - len[link[i]];
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("GeneralSuffixAutoMaton.in", "r", stdin);
  freopen("GeneralSuffixAutoMaton.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
